using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ACT_TASKMap : EntityTypeConfiguration<ACT_TASK>
    {
        public ACT_TASKMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Subject)
                .HasMaxLength(100);

            this.Property(t => t.Subject_RecordType)
                .HasMaxLength(30);

            this.Property(t => t.Subject_RecordID)
                .HasMaxLength(30);

            this.Property(t => t.Status)
                .HasMaxLength(2);

            this.Property(t => t.RecordType)
                .HasMaxLength(30);

            this.Property(t => t.RecordID)
                .HasMaxLength(30);

            this.Property(t => t.Duration)
                .HasMaxLength(10);

            this.Property(t => t.Priority)
                .HasMaxLength(2);

            this.Property(t => t.Sender_RecordType)
                .HasMaxLength(30);

            this.Property(t => t.Sender_RecordID)
                .HasMaxLength(30);

            this.Property(t => t.Recipient_RecordType)
                .HasMaxLength(30);

            this.Property(t => t.Recipient_RecordID)
                .HasMaxLength(30);

            this.Property(t => t.Phone)
                .HasMaxLength(50);

            this.Property(t => t.Fax)
                .HasMaxLength(50);

            this.Property(t => t.Email)
                .HasMaxLength(100);

            this.Property(t => t.Direction)
                .HasMaxLength(10);

            this.Property(t => t.Type)
                .HasMaxLength(20);

            this.Property(t => t.Address)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("ACT_TASK");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.Subject_RecordType).HasColumnName("Subject_RecordType");
            this.Property(t => t.Subject_RecordID).HasColumnName("Subject_RecordID");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.CreatedOn).HasColumnName("CreatedOn");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.RecordID).HasColumnName("RecordID");
            this.Property(t => t.Duration).HasColumnName("Duration");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.Due_Date).HasColumnName("Due_Date");
            this.Property(t => t.Due_Hour).HasColumnName("Due_Hour");
            this.Property(t => t.Due_Minute).HasColumnName("Due_Minute");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.Sender_RecordType).HasColumnName("Sender_RecordType");
            this.Property(t => t.Sender_RecordID).HasColumnName("Sender_RecordID");
            this.Property(t => t.Recipient_RecordType).HasColumnName("Recipient_RecordType");
            this.Property(t => t.Recipient_RecordID).HasColumnName("Recipient_RecordID");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Fax).HasColumnName("Fax");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Direction).HasColumnName("Direction");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.InitiatedBy).HasColumnName("InitiatedBy");

            // Relationships
            this.HasOptional(t => t.ACT_Category)
                .WithMany(t => t.ACT_TASK)
                .HasForeignKey(d => d.Category);
            this.HasOptional(t => t.ACT_InitiatedBy)
                .WithMany(t => t.ACT_TASK)
                .HasForeignKey(d => d.InitiatedBy);
            this.HasOptional(t => t.Name)
                .WithMany(t => t.ACT_TASK)
                .HasForeignKey(d => d.CreatedBy);

        }
    }
}
